package search

func BinarySearch(array []int, findData int) int {
	low := 0
	high := len(array) - 1
	for low <= high {
		mid := (low + high) / 2
		if array[mid] > findData {
			high = mid - 1
		} else if array[mid] < findData {
			low = mid + 1
		} else {
			return mid
		}
	}
	return -1
}
